package com.ayq.activiti.manager.enums;

/**
 *
 * <p>节点类型枚举</p>
 * @Author ayq
 * @Date 2021/4/16 9:27
 */
public enum NodeInfoEnum {

    STARTEVENT(1,"StartEvent"),
    USERTASK(2,"UserTask"),
    SERVICETASK(3,"ServiceTask"),
    MANUALTASK(4,"ManualTask"),
    EXCLUSIVEGATEWAY(5,"ExclusiveGateway"),
    PARALLELGATEWAY(6,"ParallelGateway"),
    EndEvent(7,"EndEvent"),
    SEQUENCEFLOW(8,"SequenceFlow"),
    ERROR(-1,"节点类型不匹配");
    private Integer code;

    private String key;

    NodeInfoEnum(Integer code, String key) {
        this.code = code;
        this.key = key;
    }

    public static NodeInfoEnum getResultEnum(int number) {
        for (NodeInfoEnum type : NodeInfoEnum.values()) {
            if (type.getCode()== number) {
                return type;
            }
        }
        return ERROR;
    }

    public static NodeInfoEnum getResultEnum(String key) {
        for (NodeInfoEnum type : NodeInfoEnum.values()) {
            if (type.getKey().equals(key)) {
                return type;
            }
        }
        return ERROR;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }
}
